<template>
  <BaseQuery>
    <BaseQueryLeft :span="2">
      <el-button type="primary" icon="el-icon-plus" :size="formSize" @click="add">新增</el-button>
    </BaseQueryLeft>
    <BaseQueryRight :span="22">
      <el-form :model="form" :inline="true" :size="formSize">
        <el-form-item label="渠道名称:">
          <el-input v-model="form.name" clearable placeholder="请输入查询的产品名称" />
        </el-form-item>
        <el-form-item>
          <el-button type="primary" icon="el-icon-search" @click="search">查询</el-button>
        </el-form-item>
      </el-form>
    </BaseQueryRight>
  </BaseQuery>
</template>

<script>
export default {
  name: "QueryForm",
  props: {
    value: {
      type: Object,
      default: () => {},
    },
  },
  data() {
    return {
      form: {},
      formSize:'small'
    };
  },
  watch: {
    value: {
      handler(val) {
        this.form = val;
      },
      deep: true,
      immediate: true,
    },
    form: {
      handler(val) {
        this.$emit("input", val);
      },
      deep: true,
    },
  },
  methods: {
    search() {
      this.$parent.page.page = 1;
      this.$emit("search");
    },
    add() {
      this.$parent.addProduct();
    },
  },
};
</script>
